﻿using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Web;

namespace NewRen.Models
{
    public class DB : DbContext
    {
        public DB()
            : base("sqlserverdbtest")
        {

        }

        public DbSet<Business> Businesses { set; get; }
        public DbSet<Images> Images { set; get; }
        public DbSet<UserGroup> UserGroups { get; set; }
        public DbSet<User> Users { get; set; }
        public DbSet<Product> Products { get; set; }
        public DbSet<MessageBoard> MessageBoards { get; set; }
        public DbSet<Anecdote> Anecdotes { get; set; }
        public DbSet<MoneyRecord> MoneyRecords { get; set; }
        public DbSet<IntegrationRecord> IntegrationRecords { get; set; }

        public DbSet<Admin> Admins { set; get; }

        public DbSet<ValidateCode> ValidateCodes { set; get; }

        public DbSet<City> Cities { set; get; }

        public DbSet<District> Districts { set; get; }

        public DbSet<Town> Towns { set; get; }

        public DbSet<Job> Jobs { set; get; }

        public DbSet<Industry> Industries { set; get; }

        public DbSet<ProductType> ProductTypes { set; get; }

        public DbSet<Link> Links { set; get; }

        public DbSet<UserRecommend> UserRecommends { set; get; }

        public DbSet<ExchangeCode> ExchangeCodes { set; get; }

        public DbSet<Collect> Collects { set; get; }

        public DbSet<BrowseRecord> BrowseRecords { set; get; }

        public DbSet<Topic> Topics { set; get; }

        public DbSet<Reply> Replies { set; get; }

        public DbSet<Plate> Plates { set; get; }

        public DbSet<ForumSign> ForumSigns { get; set; }

        public DbSet<SignRecord> SignRecords { set; get; }

        public DbSet<SearchHot> SearchHots { set; get; }


        public DbSet<SysSetting> SysSettings { set; get; }

        public DbSet<Picture> Pictures { set; get; }

        public DbSet<Province> Provinces { set; get; }

        public DbSet<Board> Boards { set; get; }

        public DbSet<PlateOwner> PlateOwners { set; get; }

        public DbSet<Log> Logs { set; get; }

        public DbSet<News> News { set; get; }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
              modelBuilder.Entity<MessageBoard>().HasRequired(mb => mb.ToUser).WithMany().WillCascadeOnDelete(false);
             modelBuilder.Entity<Topic>().HasRequired(t => t.User).WithMany().WillCascadeOnDelete(false);
        }
    }
}
